<div class="clear mainbox-title-container">

	<h1 class="mainbox-title float-left"><?php
		if ( isset($_GET['user_type']) ) {
			switch ($_GET['user_type']) {
				case 'A':
					echo t('Administrators');
					break;
				case 'B':
					echo t('Content Providers');
					break;
				case 'F':
					echo t('Cộng tác viên');
					break;
				case 'C':
				default:
					echo t('Customers');
					break;
			}
		}
	?></h1>

	<div class="tools-container">
		<span class="action-add">
			<?php if ( isset($_GET['user_type']) ) {
				switch ($_GET['user_type']) {
					case 'A':
						echo CHtml::link(t('Add administrator'), array('/user/add', 'user_type' => 'A'));
						break;
					case 'B':
						echo CHtml::link(t('Add CP'), array('/user/add', 'user_type' => 'B'));
						break;
					case 'F':
						echo CHtml::link(t('Add CTV'), array('/user/addCTV'));
						break;
					case 'C':
					default:
						echo CHtml::link(t('Add customer'), array('/user/add', 'user_type' => 'C'));
						break;
				}
			} ?>
		</span>
	</div>
</div>

<div class="mainbox-body">
 <?php $this->renderPartial('com/search_form', array(
	'filter' => @$filter,
	'put_request_vars' => array(
		'user_type' => @$_GET['user_type'],
	)
)); ?>
	
<?php

$this->widget('ext.EGridView', array
(
	'id' => 'users-list',
	'cssFile' => false,
	'dataProvider' => $dataProvider,
	//'filter' => $users,
	'columns' => array (
		array (
			'header' => t('ID'),
			'headerHtmlOptions' => array('width' => '2%', 'class' => 'center'),
			'name' => 'user_id',
			'htmlOptions' => array(),
		),
		array (
			'header' => t('Username'),
			'name' => 'name',
			'htmlOptions' => array(),
			'type' => 'raw',
			'value' => 'CHtml::link($data->name, array("user/update", "id" => $data->user_id))',
		),
		array (
			'header' => t('Email'),
			'headerHtmlOptions' => array('width' => '20%'),
			'name' => 'email',
			'type' => 'raw',
			'htmlOptions' => array(),
			'value' => 'CHtml::link($data->email, array("user/update", "id" => $data->user_id))',
		),
		array (
			'header' => t('Registered Date'),
			'headerHtmlOptions' => array('width' => '15%'),
			'name' => 'email',
			'value' => 'date(app()->params["longDateFormat"], $data->timestamp)',
			'htmlOptions' => array(),
		), 
		array(
			'header' => t('Status'),
			'headerHtmlOptions' => array('width' => '10%'),
			'class' => 'MyStatusColumn',
			"update_controller" => "user",
			"update_action" => "updateStatus",
			"id_field" => 'user_id',
		),
		array(
			'headerHtmlOptions' => array('width' => '5%'),
			'class'=>'CButtonColumn',
			'template'=>'{delete}{update}',
			'deleteButtonUrl' => 'Yii::app()->createUrl("/user/delete", array("id" =>  $data->user_id))',
			'updateButtonUrl' => 'Yii::app()->createUrl("/user/update", array("id" =>  $data->user_id))',
		),
	),
));

?>

</div>